import { RouterModule, Routes } from '@angular/router';
import { NgModule } from '@angular/core';

import { PagesComponent } from './pages.component';
import { MainComponent } from './main/main.component';
import { NotFoundComponent } from './miscellaneous/not-found/not-found.component';

// 默认使用了main路由，注意这个地方没有使用惰性加载，直接用的MainComponent，所以要在PagesModule
// 导入MainModule
const routes: Routes = [{
  path: '',
  component: PagesComponent,
  children: [{ // 并非懒加载，所有要先导出模块
    path: 'main',
    component: MainComponent,
  }, {
    path: '',
    redirectTo: 'main',
    pathMatch: 'full',
  }, {
    path: 'realtime',
    loadChildren: './realtime/realtime.module#RealtimeModule',
  },
  {
    path: 'dynamics',
    loadChildren: './dynamics/dynamics.module#DynamicsModule',
  }, {
    path: 'governance',
    loadChildren: './governance/governance.module#GovernanceModule',
  }, {
    path: '**',
    component: NotFoundComponent,
  }],
}];

@NgModule({
  imports: [RouterModule.forChild(routes)],
  exports: [RouterModule],
})
export class PagesRoutingModule {
}
